<?php
// +----------------------------------------------------------------------
// | Index.
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.suckseed.cn, All rights reserved.
// +----------------------------------------------------------------------
// | Author: wjf <184521508@qq.com> 2017-07-04
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\model\AdminMenu;
use think\Db;
use wjf\controller\AdminBase;

class Index extends AdminBase
{
    public function _initialize()
    {
        $adminSettings = wjf_get_option('admin_settings');
        if (empty($adminSettings['admin_password']) || $this->request->path() == $adminSettings['admin_password']) {
            $adminId = wjf_get_current_admin_id();
            if (empty($adminId)) {
                session("__LOGIN_BY_WJF_ADMIN_PW__",1);//设置后台登录加密码
            }
        }
        parent::_initialize();
    }
    /**
     * 后台首页
     */
    public function index(){
        $adminMenuModel = new AdminMenu();
        $menus = $adminMenuModel->menuTree();

        $this->assign("menus",$menus);

        $admin = Db::name('user')->where('id',wjf_get_current_admin_id())->find();
        $this->assign('admin',$admin);
        return $this->fetch();
    }
}